package com.chenchao.javaprocesscontrol;

import com.sun.org.glassfish.gmbal.Description;

/**
 * @encoding : UTF-8
 * @Time : 2020/11/6 19:59
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.javaprocesscontrol.JavaFor.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 */
public class JavaFor {
    public static void main(String[] args) {
        //JavaFor.oeSum(100);
        //JavaFor.printFiveMultiples(100);
        JavaFor.nine_nine_multiplication_table();
    }

    /**
     * oeSum 分别打印传入参数范围类的奇偶数和
     *
     * @param maxRange 就和最大值（包括）
     */
    public static void oeSum(int maxRange) {
        int oddSum = 0;
        int evenSum = 0;
        for (int i = 0; i < maxRange; i++) {
            if (i % 2 == 0) {
                evenSum += i;
            } else {
                oddSum += i;
            }
        }
        System.out.println(maxRange + "范围内的奇数和为" + oddSum);
        System.out.println(maxRange + "范围内的偶数和为" + evenSum);
    }

    /**
     * printFiveMultiples 分三行打印5的倍数
     *
     * @param range 范围
     */
    public static void printFiveMultiples(int range) {
        for (int i = 1; i < range; i++) {
            if (i % 5 == 0) {
                System.out.print(i + "\t");
            }
            if (i % 15 == 0) {
                System.out.println();
            }
        }
    }

    /**
     * nine_nine_multiplication_table 打印九九乘法表
     */
    public static void nine_nine_multiplication_table() {
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < i; j++) {
                System.out.print(i + "*" + j + "=" + i * j + "\t");
            }
            System.out.println();
        }
    }
}
